package com.csu54sher.basereservation.configuration;

import com.csu54sher.basereservation.Interceptor.JWTInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
@Slf4j
public class WebMVCConfigutation extends WebMvcConfigurationSupport {
    @Autowired
    private JWTInterceptor jwtInterceptor;

    /**
     * 注册自定义拦截器，只不拦截登录和注册接口
     * @param registry
     * @author liuke
     */
    // 在 WebMVCConfigutation.java 中修改为更明确的路径模式

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login", "/register");
    }
}
